/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.teklif;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.ihale.database.DatabaseYakup;
import org.ihale.satinalmaci.SatinAlmaciBean;



/**
 *
 * @author yakup
 */
@ManagedBean(name = "teklifbean" )
@ViewScoped

public class TeklifBean implements Serializable{
    private List<Teklif> teklifler = new LinkedList<Teklif>();
 private Teklif endusuk_teklif=new Teklif();

    public Teklif getEndusuk_teklif() {
        return endusuk_teklif;
    }

     private Teklif minTeklif = new Teklif();

    public List<Teklif> getTeklifler() {
        return teklifler;
    }

    public void setTeklifler(List<Teklif> teklifler) {
        this.teklifler = teklifler;
    }

    public TeklifBean() {
         SatinAlmaciBean satinAlmaciBean = new SatinAlmaciBean();
         satinAlmaciBean = (SatinAlmaciBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("satinalmacibean");
         teklifler = satinAlmaciBean.getTeklifler();
         minTeklif = satinAlmaciBean.getMinTeklif();
         endusuk_teklif=satinAlmaciBean.getMinTeklif();

       // teklifler = 
    }
    
    
    public void guncelleTeklifler(){
        try {
            DatabaseYakup dby = new DatabaseYakup();
            SatinAlmaciBean satinAlmaciBean = new SatinAlmaciBean();
            satinAlmaciBean = (SatinAlmaciBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("satinalmacibean");
            dby.connect();
           // teklifler = dby.getirSimdikiIhaleler(satinAlmaciBean.getSecilenIhaleToGoruntule());
            teklifler = dby.getirSonTeklifler(satinAlmaciBean.getSecilenIhaleToGoruntule());
            minTeklif = dby.minTeklifiGetir(satinAlmaciBean.getSecilenIhaleToGoruntule());
            dby.disconnect();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(TeklifBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(TeklifBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    
    }
    
    
    
    public Teklif getMinTeklif() {
        return minTeklif;
    }

    public void setMinTeklif(Teklif minTeklif) {
        this.minTeklif = minTeklif;
    }
    
  
   
    
}
